/*
 * TowerControlInbox.cpp
 *
 *  Created on: Sep 10, 2013
 *      Author: gonprieto
 */

#include "TowerControlInbox.h"
#include "../DTO/DTOFlightGeneratorEnded.h"
#include "../../utils/Logger.h"

TowerControlInbox::TowerControlInbox(std::string fifoName,bool isForRead) : FifoProtocoloPlano(fifoName,isForRead) {
	this->isRunning = true;
}

TowerControlInbox::~TowerControlInbox() {
	Logger::instancia() << "TowerControlInbox::~TowerControlInbox" << eol ;
}

void TowerControlInbox::flightControllerRequest(DTOFlightControlerRequest dto){
	Logger::instancia() << "TowerControlInbox::flightControllerRequest - entro" << eol ;
	escribirDTO(dto);
	Logger::instancia() << "TowerControlInbox::flightControllerRequest - salio" << eol ;
}

void TowerControlInbox::requeueVuelo(DTOFlightRelated* dto){
	Logger::instancia() << "TowerControlInbox::requeueVuelo" << eol ;
	escribirDTO(*dto);
}

void TowerControlInbox::requeueRequest(DTOFlightControlerRequest* dto){
	Logger::instancia() << "TowerControlInbox::requeueRequest" << eol ;
	escribirDTO(*dto);
}

void TowerControlInbox::endFlightGenerator(){
	Logger::instancia() << "TowerControlInbox::endFlightGenerator" << eol ;
	DTOFlightGeneratorEnded dto = DTOFlightGeneratorEnded();
	escribirDTO(dto);
}

void TowerControlInbox::newFlightArrival(DTOFlightRelated newflight){
	Logger::instancia() << "TowerControlInbox::newFlightArrival" << eol ;
	escribirDTO(newflight);
}

void TowerControlInbox::releaseRunway(unsigned int runwayId){
	Logger::instancia() << "TowerControlInbox::releaseRunway" << eol ;
	DTORunwayRelated rr(RELEASE_RUNWAY,runwayId);
	escribirDTO(rr);
}
